#ifndef GRAPHICS_FACTORY_H_
#define GRAPHICS_FACTORY_H_

#include "factory.h"
#include "fontmaterial.h"
#include "material.h"
#include "log.h"
#include <map>

class CGraphicsFactory : public CFactory
{
	
private:
	
	CFactoryLine_Map * m_pMaterialLine;
	CFactoryLine_Map * m_pRawMaterialLine;

	inline CMaterialFrame * LoadMaterialFrame( std::string s )
	{
		
		CMaterialFrame * f = new CMaterialFrame;
		f->Load( s );
		m_pRawMaterialLine->Add( s, f );
		
		return f;
		
	}
	
	inline CMaterialFrame * CopyMaterialFrame( std::string s, CMaterialFrame * f )
	{
	
		CMaterialFrame * srcFrame;
		
		srcFrame = GetMaterialFrame( s );
		
		if( srcFrame )
		{

			srcFrame->CopyOver( f );
			return srcFrame;
		} 
		
		return NULL;
		
	}

	inline CMaterialFrame * GetMaterialFrame( std::string s )
	{

		return ( CMaterialFrame * )m_pRawMaterialLine->Get( s );
		
	}
	
public:
	
	inline CMaterial * Find( std::string file )
	{
		
		CMaterial * m = NULL;
		m = ( CMaterial * )m_pMaterialLine->Find( file );
		
		if( m == NULL )
			m = LoadMaterial( file );
		
		return m;
		
	}
	
	inline CFontMaterial * GetFont( std::string name )
	{
		
		return ( CFontMaterial * )m_pMaterialLine->Find( name );
		
	}

	
	CMaterial * LoadMaterial( std::string );

	CFontMaterial * LoadFont( std::string, std::string, int );
	
	CGraphicsFactory();
	virtual ~CGraphicsFactory();
	
};

#endif
